﻿/*
 * Managed ESL Suite
 * 
 * Version: MPL 1.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 * 
 * The Initial Developer of the Original Code is
 * Diego Toro <dftoro@yahoo.com>
 * Portions created by the Initial Developer are Copyright (C)
 * the Initial Developer. All Rights Reserved.
 * 
 * Contributor: 
 * Diego Toro <dftoro@yahoo.com>
 * 
 * ChannelEvent.cs
*/

using System;
using System.Collections.Generic;
using System.Linq;

namespace Managed.Esl.Suite
{
  public class ChannelEvent : EventBase
  {
    #region field

    #region Minimum event information

    private string stChannelState;
    private int inChannelStateNumber;
    private string stChannelName;

    #endregion Minimum event information

    #endregion field

    #region Property

    public string ChannelState
    {
      get { return stChannelState; }
    }

    public int ChannelStateNumber
    {
      get { return inChannelStateNumber; }
    }

    public string ChannelName
    {
      get { return stChannelName; }
    }

    #endregion Property

    #region Constructor

    public ChannelEvent(ESLevent eslEvent)
      : base(eslEvent)
    {
      LoadDefaultProperties();
    }

    public ChannelEvent(string type, string subClassName)
      : base(type, subClassName)
    {
      LoadDefaultProperties();
    }


    #endregion Constructor

    #region Private Member

    private void LoadDefaultProperties()
    {
      string stTemp = eslEvent.GetHeader("channel-state");
      stChannelState = String.IsNullOrEmpty(stTemp) ? String.Empty : stTemp;

      stTemp = eslEvent.GetHeader("channel-name");
      stChannelName = String.IsNullOrEmpty(stTemp) ? String.Empty : stTemp;

      stTemp = eslEvent.GetHeader("channel-state-number");
      inChannelStateNumber = String.IsNullOrEmpty(stTemp) ? -1 : int.Parse(stTemp);
    }

    #endregion Private Member

  }
}
